import { computed, ref } from "vue";
import useUserStore from '@/store/modules/user';
import { session, local } from '@/service/storage.service';


export function useUser() {
  const userStore = useUserStore();
  const userState = computed(() => userStore.user||{})

  const logout = () => {
    userStore.clearUser();
    session.clear();
    local.clear();
    uni.reLaunch({
      url: '/pages/login/index',
    })
  }

  return {
    userState,
    logout
  }
}